/**
 * @author Zvonimir Fras <zvonimir@frasbros.com>
 */

#include "./synapse.h"
#include "neuron.h"


Synapse::Synapse(QObject* parent) : QObject( parent )
{
   setRandomWeight();
   m_left = 0;
   m_right = 0;
}

void Synapse::setWeight(float weight)
{
   m_weight = weight;
   m_right->setOutputNeedsUpdate();
}

float Synapse::weight()
{
   return m_weight;
}

void Synapse::setRandomWeight()
{
   m_weight = ((float)qrand()/RAND_MAX) - 0.5f;
}



void Synapse::prependNeuron(Neuron* neuron)
{
   m_left = neuron;
}


void Synapse::appendNeuron(Neuron* neuron)
{
   m_right = neuron;
}

Neuron* Synapse::leftNeuron()
{
   return m_left;
}

Neuron* Synapse::rightNeuron()
{
   return m_right;
}



